Skip to main content

RESTful Engine Python Client Reference

This article describes how to get the Fluent RESTful V2 .NET Standard client installed, as well as a list of all methods and models defined in the client.

Important

You must use Python 3.8.6 (64bit) for this client to run on your machine. You can get that here.

Setting Up the Client

note

To see a sample application using the Fluent RESTful V2 .NET Standard client, please refer to our sample Java application github page.

To set up the client, run the following command in the command prompt: pip install windwardrestapi==21.0.0.11 Then in your project, include this line: from windwardrestapi.Api import WindwardClient as Client Then to initialize the client: client = Client.WindwardClient("[RESTful URL]") Now, the client is setup and you can call the different methods associated with it.

Client Models

info

This section will go over the relevant models associated with the client that you will use. To import the models into your project, use: from windwardrestapi.Model import *

Template

These are the parameters for the Template object constructor:

:param callback : If set, this url will be called with a POST when a job completes. If the text "{guid}" is in the url, that text will
be replaced with the Guid for the callback.
:type str

:param outputFormat : The desired output file type (set using the Template.OutputFormatEnum())
:type str

:param data : The file path for your template (the client will encode to base64) (only use if connectionString is None)
:type str : string representation of the file path

:param connectionString : The connection string to your template file (only use if data is None)
:type str

:param format : The format of the template to be processed (if left empty it will auto populate)
:type str

:param properties : Fluent properties for this report. These override any properties set in the configuration file on the server side.
:type List[Property] : A list of Property objects

:param parameters : A set of input parameters for this report. The parameters are global and shared among all data sources.
:type List[Parameter] : A list of Property objects

:param datasources : The datasources to apply to the template. The datasources are applied simultaneously.
:type List[Datasource] : A list of Datasource objects

:param tag : A tag you want to assign to the template.
This is passed in to the repository job handlers and is set in the final generated Report object
:type str

:param trackImports : Return all imports with the generated document
:type bool

:param trackErrors : Enable or disable the error handling and verify functionality.
:type bool

:param mainPrinter : If you are using printer output use to specify main printer. Printer must be recognized by Network
:type str

:param firstPagePrinter : Set first page printer if main printer is already set
:type str

:param printerJobName : Assign the print job a name
:type str

:param printCopies : Set number of copies the print job should print
:type str

:param printDuplex : Selects the printers duplex mode
:type str

When constructing the template object, explicitly set the input parameters, ie: testTemplate = Template.Template(data=file, outputFormat=Template.outputFormatEnum.DOCX, datasources=testXmlDS, parameters=testParam)

testTemplate = Template.Template(data=file, outputFormat=Template.outputFormatEnum.DOCX, datasources=testXmlDS, parameters=testParam, ...)

Only set the input parameters that apply to your report. You must have either the data input parameter or the connectionString input parameter set.

XML 1.0 Data Source

These are the input parameters for the XML 1.0 data source constructor:

:param name : The datasource name that maps to the datasource attribute in tags
:type str

:param connectionString : The connection string to the XML1 data (only use if data is None)
:type str

:param data : The file path to the XML1 data file (only use if connectionString is None)
:type str : the file path to the XML1 data file as a string

:param schemaConnectionString : The connection string to the XSD file. None if no schema
:type str

This is how you instantiate the object:

testXmlDS = Xml_10DataSource.Xml_10DataSource(name="MANF_DATA_2009", data=data)

SQL Data Source

These are the input parameters for the SQL data source constructor:

:param name : The datasource name that maps to the datasource attribute in tags
:type str

:param className : The ADO.NET connector classname
:type str

:param connectionString : The connection string to the SQL data
:type str

This is how you instantiate the object:

testSqlDS = SqlDataSource.SqlDataSource(name= "", ...)

Salesforce OAuth Data Source

These are the input parameters for the SalesforceOauth data source constructor:

:param name : The datasource name that maps to the datasource attribute in tags
:type str

:param connectionString : The connection string to the SalesforceOAuth data
:type str

This is how you instantiate the object:

testSalesforceOAuthDS = SalesforceOAuthDataSource.SalesforceOAuthDataSource(name= "", connectionString = "")

Salesforce Data Source

These are the input parameters for the Salesforce data source constructor:

:param name : The datasource name that maps to the datasource attribute in tags
:type str

:param connectionString : The connection string to the Salesforce data
:type str

This is how you instantiate the object:

testSalesforceDS = SalesforceDataSource.SalesforceDataSource(name= "", connectionString = "")

OData Data Source

These are the input parameters for the OData data source constructor:

:param name : The datasource name that maps to the datasource attribute in tags
:type str

:param connectionString : The connection string to the OData data
:type str

This is how you instantiate the object:

testODataDS = ODataDataSource.ODataDataSource(name= "", connectionString = "")

JSON Data Source

These are the input parameters for the JSON data source constructor:

:param name : The datasource name that maps to the datasource attribute in tags
:type str

:param connectionString : The connection string to the JSON data file (only use if data is None)
:type str

:param data : The file path to the JSON data file (only use if connectionString is None)
:type str : the file path to the JSON data file as a string

This is how you instantiate the object:

testJsonDS = JsonDataSource.JsonDataSource(name= "", ...)

Parameter

These are the input parameters for the Parameter constructor:

:param name : The name of the property
:type str

:param value: The value of the property. You can pass any primitive, null, a DateTime, or DateTimeOffset. You cannot pass lists or arrays
:type object

(Parameter value explained next) The template object takes in a list of Parameter objects, so if you have multiple, append them to an array and pass them in that way. This is how you instantiate on parameter:

testParam = Parameter.Parameter(name="varName1", wrappedValue= ParameterValue.ParameterValue(paramType ="[the type of the parameter]", rawValue = "[the actual value of the param]"))

You could also just construct the ParameterValue object outside of this line and then include it:

testParamValue = ParameterValue.ParameterValue(paramType = "[the type of the parameter]", rawValue = "[the actual value of the param]")
testParam = Parameter.Parameter(name="varName1",testParamValue)

ParameterValue

If your template has parameters, use this model for the wrappedValue in the Parameter constructor. These are the input parameters for the ParamValue constructor:

:param ParamType : What type the raw value needs to be converted back to.
:type str

:param RawValue: The parameter value as a string.
:type str

This is how you instantiate the object:

testParamValue = ParameterValue.ParameterValue(paramType = "[the type of the parameter]", rawValue = "[the actual value of the param]")

Client Methods

Client Constructor

Input Parameters:

:param Uri: The uri to your RESTful engine instance
:type str

:param licenseKey: Optional parameter if you wanted to process a report with a specific license key.
:type str

This is how you would call it:

client = Client.WindwardClient(restful_engine_url))

Client.GetVersion()

This method is used to get the version information with regards to the server and the local client. No input parameters. How to call:

version = client.getVersion()

Returns version data.

Client.postDocument(Template t)

This method is used to post the constructed template object to the RESTful engine. Takes in a Template object How to call:

document = client.postDocument(template)

Returns a document object.

Client.getDocumentStatus(string GUID)

This method is used to get the status of the document being processed. You MUST use this method to check the status of the document before getting the document back. How to call:

 status = client.getDocumentStatus(guid)

This is how we recommend using this in your application:

while True:
testDocumentStatus = testClient.getDocumentStatus(testDocument.guid)
'The document is ready when the status is 302 (this is different for different endpoints'
if testDocumentStatus != 302:
print("Not ready: ", testDocumentStatus)
time.sleep(1)
else:
print("Ready: ", testDocumentStatus)
break

We need to wait until GetDocumentStatus() returns 302. The method returns Http status codes.

Client.getDocument(string GUID)

This method is used to get the document after its done processing. You pass to it the Guid:

document = client.getDocument(guid)

This method returns the document object.

Client.deleteDocument(string guid)

This method is used to delete the document after its done processing. You pass to it the Guid:

document = client.deleteDocument(guid)